package net.skyedu.service.frame;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.skyedu.bean.UserInfo;
import net.skyedu.dao.UserInfoDao;

public class Index extends HttpServlet {

	private static final long serialVersionUID = -7452492747665303419L;

	public Index() {super();}

	public void destroy() {super.destroy();}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		doPost(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		String str=request.getParameter("$");
//		System.out.println(str);
		String a = null;
		int u = 0;
		if(str.length()>17){
		 	a=str.substring(5,str.indexOf("/")); 
		 	u=Integer.parseInt(a);
		}
		UserInfoDao ud=new UserInfoDao();
		UserInfo user = ud.getSSN1(u);
		if(user != null){
			request.setAttribute("u", u);
			request.getRequestDispatcher("/attend/frame/default.jsp").forward(request,response);
		}else{
			request.setAttribute("message", "由于您刚入职不久，考勤数据未同步OA，请联系信息技术中心！工作时间周二至周六：9：30--18：00！");
			request.getRequestDispatcher("attend/408.jsp").forward(request, response);
		}
	}

	
	
	public void init() throws ServletException {}
}
